// pages/mine/yaoqing/add/add.js
const $api = require("../../../../api/mine").API
Page({

  /**
   * 页面的初始数据
   */
  data: {
    'member_name':'',
    'member_mobile':'',
    'parent_role_name':'',
    'child_id':wx.getStorageSync('child_one').child_id,
    'member_id':wx.getStorageSync('user').member_id
  },
  onShow: function () {

  },
  //获取姓名
  getMmember_name(e){
    var t = this
    console.log(e.detail);
    t.setData({
      'member_name':e.detail
    })
  },
  //获取电话
  getMember_mobile(e){
    var t = this
    console.log(e.detail);
    t.setData({
      'member_mobile':e.detail
    })
  },
  //获取角色
  getParent_role_name(e){
    var t = this
    console.log(e.detail);
    t.setData({
      'member_name':e.detail
    })
  },
  // 点击提交
  tijiao(e){
    var t = this,
    // console.log(t.data.member_id)
    data = {
      'child_id':t.data.child_id,
      'member_name':t.data.member_name,
      'member_mobile':t.data.member_mobile,
      'parent_role_name':t.data.parent_role_name,
      'member_id':t.data.member_id,
    }
    $api.saveFamily(data).then(res=>{
      console.log(res)
      if(res.status==200){
        wx.showToast({
          title: '添加成功',
        })
        setTimeout(function(){
         wx.navigateTo({
           url: '/pages/mine/yaoqing/yaoqing',
         })
        },1000)
      }
    })

    
  }
})